package com.ryan.plugin.store;

import java.util.Objects;

public class AClass {
    public String packageName;
    public String className;
    public String tag;
    public String from;

    public AClass(String packageName, String className) {
        this.packageName = packageName;
        this.className = className;
    }

    public String getQualifiedName() {
        return packageName + "." + className;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AClass aClass = (AClass) o;
        return getQualifiedName().equals(aClass.getQualifiedName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getQualifiedName());
    }

    @Override
    public String toString() {
        return packageName + "." + className + (isEmpty(tag) ? "" : ("(" + tag + ")")) +
                (isEmpty(from) ? "" : ("(from: " + from + ")"));
    }

    private boolean isEmpty(String s) {
        return s == null || s.equals("");
    }
}
